package com.example.demo.controller;

import com.example.demo.entity.User;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Name
 * @Author 村头老杨头
 * @Date 2022/9/27 8:00
 * @Description
 **/
@RestController
public class UserController {
    @Autowired
    private UserService userService;


    @GetMapping("getUser")
    @CrossOrigin
    public User getUserByUid(Integer uid){
        return userService.getUserByID(uid);
    }
    @GetMapping("getUsers")
    @CrossOrigin
    public List<User> getUsers(){
        return userService.getUsers();
    }
    @PostMapping("addUser")
    @CrossOrigin
    public int addUser(User user){
        return userService.addUser(user);
    }


}
